package com.liuyang.demo.collection;

import java.util.Arrays;
import java.util.List;

public class ForReturnDemo {

    public static void main(String[] args) {
        List<Integer> list = Arrays.asList(1,2,3,4);
        list.forEach(i-> {
            if (i==2){
                return;
            }
            System.out.println(i);
        });
        System.out.println("forEach-return，不中断");
        for (Integer i :
                list) {
            if (i == 2) {
                break;
            }
            System.out.println(i);
        }
        System.out.println("------------------");

    }
}
